﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 文档 逻辑类
    /// </summary>
    public partial class Document
    {
        /// <summary>
        /// 文档数据类
        /// </summary>
        private DAL.Document documentDAL = new DAL.Document();

        /// <summary>
        /// 构造函数
        /// </summary>
        public Document()
        {
        }
        /// <summary>
        /// 获得单个缩略图路径
        /// <creator>wangl</creator>
        /// <date>2013-09-06</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docId">信息编号</param>
        /// <returns>缩略图路径</returns>
        public string GetDocFThumbSrvFileName(string entityNo, decimal docId)
        {
            return documentDAL.GetDocFThumbSrvFileName(entityNo, docId);
        }
        /// <summary>
        /// 获取文档实体类
        /// <creator>wangl</creator>
        /// <date>2013-08-07</date> 
        /// </summary>
        /// <param name="docId">文档编号</param>
        /// <returns>文档实体类</returns>
        public Model.Document GetModel(decimal docId)
        {
            return documentDAL.GetModel(docId);
        }
        /// <summary>
        ///  判断当前登陆人员是否有权限对指定文档的查看权限
        /// <creator>wangl</creator>
        /// <date>2013-09-06</date>
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="docClsCd"></param>
        /// <param name="entityNo"></param>
        /// <param name="docId"></param>
        /// <returns></returns>
        public bool IsDocAuthorityForEmpl(string emplNo, string docClsCd, string entityNo, decimal docId)
        {
            return documentDAL.IsDocAuthorityForEmpl(emplNo, docClsCd, entityNo, docId);
        }
        /// <summary>
        ///  判断当前登陆人员是否有权限对指定文档的查看权限
        /// <creator>sunlj</creator>
        /// <date>2014-06-17</date>
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="docId"></param>
        /// <returns></returns>
        public bool IsDocumentAuthorityForEmpl(string emplNo, decimal docId)
        {
            return documentDAL.IsDocumentAuthorityForEmpl(emplNo, docId);
        }

        /// <summary>
        ///  判断当前信息是否所有人可见
        /// <creator>sunlj</creator>
        /// <date>2014-06-17</date>
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="docId"></param>
        /// <returns></returns>
        public bool IsDocumentAuthorityForEveryone(decimal docId)
        {
            return documentDAL.IsDocumentAuthorityForEveryone(docId);
        }

        /// <summary>
        /// 更新浏览次数
        /// <creator>wangl</creator>
        /// <date>2013-09-16</date>
        /// </summary>
        /// <param name="docId"></param>
        public void UpdateReadCntByDocId(decimal docId)
        {
            documentDAL.UpdateReadCntByDocId(docId);
        }
        /// <summary>
        /// 根据信息编号获取信息编号(适用于单信息)
        /// <creator>wangl</creator>
        /// <date>2013-09-10</date> 
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns></returns>
        public decimal GetDocIdDocClsCd(string entityNo, string docClsCd)
        {
            return documentDAL.GetDocIdDocClsCd(entityNo, docClsCd);
        }

                /// <summary>
        /// 获得该类别下前多少条数据
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="fDocClsCd">类别编号</param>
        /// <param name="top">多少条数据 0为全部</param>
        /// <returns>信息List</returns>
        public List<Model.Document> GetALLListByFDocClsCd(string entityNo, string fDocClsCd, int top)
        {
            return documentDAL.GetALLListByFDocClsCd(entityNo, fDocClsCd, top);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.Document> DataTableToList(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.Document> modelList = new List<ElingOA6_DSJCJ.Model.Document>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.Document model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = documentDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 更新批示状态
        /// </summary>
        /// <param name="FDocClsCd"></param>
        /// <param name="FEntityNo"></param>
        public void UpdateFisInstruct(string fdocId, string FEntityNo, string charVal)
        {
            documentDAL.UpdateFisInstruct(fdocId, FEntityNo, charVal);
        }

        



    }
}
